Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TNO-1136 Set tone by user #2251

Merged
merged 3 commits into from
Sep 5, 2024
Merged

TNO-1136 Set tone by user #2251

merged 3 commits into from
Sep 5, 2024

Conversation

areyeslo
Copy link
Collaborator

@areyeslo areyeslo commented Sep 4, 2024

Feature Update: User-Defined Tone Assessment for Articles

This update introduces the ability for subscribers to assess and set a personal tone for an article, independent of the original tone. The custom tone selected by the user will be saved and associated with their account, ensuring that their personal assessment is retained without altering the article's original tone data.

User Tone:
image

Editor Tone:
image

In DB, a record is created on tone_pool table which is used to tone any content. When the user set a tone for a content, it is saved in content_tone table.

Story: https://citz-gdx.atlassian.net/browse/TNO-1136

@areyeslo areyeslo force-pushed the TNO-1136-SetToneByUser branch 2 times, most recently from 2967acf to bc45f09 Compare September 4, 2024 04:15
@Fosol Fosol added enhancement New feature or request subscriber PR contains changes towards the subscriber application, labels Sep 4, 2024
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[SwaggerOperation(Tags = new[] { "TonePool" })]
[ETagCacheTableFilter("tone_pools")]
[ResponseCache(Duration = 5 * 60)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make sense on a POST endpoint

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

[ProducesResponseType(typeof(TonePoolModel), (int)HttpStatusCode.Created)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[SwaggerOperation(Tags = new[] { "TonePool" })]
[ETagCacheTableFilter("tone_pools")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make sense on a POST endpoint

[ProducesResponseType(typeof(IEnumerable<TonePoolModel>), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NotModified)]
[SwaggerOperation(Tags = new[] { "TonePool" })]
[ETagCacheTableFilter("tone_pools")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make sense on an endpoint that returns one item.

[ProducesResponseType((int)HttpStatusCode.NotModified)]
[SwaggerOperation(Tags = new[] { "TonePool" })]
[ETagCacheTableFilter("tone_pools")]
[ResponseCache(Duration = 5 * 60)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested findbyId, just findByUserId. Going to test it.

name: `${userId}`,
ownerId: userId,
});
const newTonePool = await getMyTonePool(userId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra request isn't needed, just use the returned tonepool from the addMyTonePool.

/// <summary>
/// get/set - Tone for the content
/// </summary>
public int? Tone {get;set;}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you even using this property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is from the previous implementation. Thank you!

{() => (
<Form>
<FormikSentiment
name="tonePools"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you correctly named this component then the Formik setFieldValue would work correctly. and you wouldn't need also include the onSentimentChange logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd need to check this by chat. I'd love to implement this way :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using FormikSentiment component.

updatedTonePools = [...(tonePools || []), { ...defaultTonePool, value: option }];
}

setFieldValue(name.toString(), updatedTonePools, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both of these can result in odd state. Formik will update the form context and then another separate set of state is being updated next. It is easier to maintain if you make the setFieldValue work correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using FormikSentiment.

const api = useApi(options);

return React.useRef({
getTonePools: (etag: string | undefined = undefined) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint doesn't appear to exist.

],
"lib": ["dom", "dom.iterable", "esnext"],
"paths": {
"@assets/*": ["../../../../app/subscriber/public/assets/*"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the need for this? Shouldn't we keep tno-core assets locally? If it's the shared library then the apps that use the shared library should be getting their components/assets from tno-core. It is also easier to maintain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for bringing this, I wanted to use the proper icons instead of applying style:
<FaSmile className="tone-icon" color="#59E9BE" />
The icons are under app/subscriber/public/assets/reports/, so I created an alias to be used in the import. Then I could use import @reports/[email protected]

@areyeslo areyeslo force-pushed the TNO-1136-SetToneByUser branch 16 times, most recently from a42d911 to 95d7d11 Compare September 5, 2024 19:43
@areyeslo areyeslo requested a review from Fosol September 5, 2024 19:54
@areyeslo areyeslo added the tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues. label Sep 5, 2024
@areyeslo areyeslo merged commit 3187930 into dev Sep 5, 2024
7 checks passed
@areyeslo areyeslo deleted the TNO-1136-SetToneByUser branch September 5, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request subscriber PR contains changes towards the subscriber application, tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants